package forum_system_test;

import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;

/**
 * @author tongchen
 * @create 2023-08-18 14:08
 */
public class RegisterTest {
    public static void main(String[] args) {
        //normalTest();
        //lackArguments();
        //RepeatRegister();
        pwdInconsistent();
    }

    /**
     * 测试正常注册功能能否实现 结果：正常注册额且进行了页面跳转
     */
    public static void normalTest(){
        ChromeDriver chromeDriver = new ChromeDriver();
        chromeDriver.get("http://47.93.222.41:58080/sign-up.html");
        chromeDriver.findElement(By.cssSelector("#username")).sendKeys("智怡张");
        chromeDriver.findElement(By.cssSelector("#nickname")).sendKeys("1111");
        chromeDriver.findElement(By.cssSelector("#password")).sendKeys("123456");
        chromeDriver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("123456");
        chromeDriver.findElement(By.cssSelector("#policy")).click();
        chromeDriver.findElement(By.cssSelector("#submit")).click();
    }
    public static void lackArguments(){
        ChromeDriver chromeDriver = new ChromeDriver();
        chromeDriver.get("http://47.93.222.41:58080/sign-up.html");
        //chromeDriver.findElement(By.cssSelector("#username")).sendKeys("智怡张");
        chromeDriver.findElement(By.cssSelector("#nickname")).sendKeys("111");
        chromeDriver.findElement(By.cssSelector("#password")).sendKeys("123456");
        chromeDriver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("123456");
        //chromeDriver.findElement(By.cssSelector("#policy")).click();
        chromeDriver.findElement(By.cssSelector("#submit")).click();
    }
    public static void RepeatRegister(){
        ChromeDriver chromeDriver = new ChromeDriver();
        chromeDriver.get("http://47.93.222.41:58080/sign-up.html");
        chromeDriver.findElement(By.cssSelector("#username")).sendKeys("张智怡");
        chromeDriver.findElement(By.cssSelector("#nickname")).sendKeys("111");
        chromeDriver.findElement(By.cssSelector("#password")).sendKeys("123456");
        chromeDriver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("123456");
        chromeDriver.findElement(By.cssSelector("#policy")).click();
        chromeDriver.findElement(By.cssSelector("#submit")).click();
    }
    public static void pwdInconsistent(){
        ChromeDriver chromeDriver = new ChromeDriver();
        chromeDriver.get("http://47.93.222.41:58080/sign-up.html");
        chromeDriver.findElement(By.cssSelector("#username")).sendKeys("张智怡");
        chromeDriver.findElement(By.cssSelector("#nickname")).sendKeys("111");
        chromeDriver.findElement(By.cssSelector("#password")).sendKeys("123456");
        chromeDriver.findElement(By.cssSelector("#passwordRepeat")).sendKeys("654321");
        chromeDriver.findElement(By.cssSelector("#policy")).click();
        chromeDriver.findElement(By.cssSelector("#submit")).click();
    }
}
